package com.yanqu.road.server.cmd.clinic;

import com.yanqu.road.pb.clinic.ClinicProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.config.ClinicMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/3/8 18:49
 */
@Cmd(code = GameProtocol.S_CLINIC_CROSS_VISIT_CLINIC, desc = "跨服来拜访")
public class CrossVisitClinicCmd extends AbstractCommand {
    private long originPlayerId;
    private long originServerId;
    private long visitPlayerId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ClinicProto.CrossVisitOtherClinicReqMsg msg = ClinicProto.CrossVisitOtherClinicReqMsg.parseFrom(packet.getBytes());
        originPlayerId = msg.getOriginPlayerId();
        originServerId = msg.getOriginServerId();
        visitPlayerId = msg.getVisitPlayerId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ClinicProto.CrossVisitOtherClinicRespMsg.Builder respMsg = ClinicProto.CrossVisitOtherClinicRespMsg.newBuilder();
        respMsg.setMsg(ClinicMgr.visitClinic(visitPlayerId));
        respMsg.setOriginPlayerId(originPlayerId);
        respMsg.setOriginServerId(originServerId);
        player.sendPacket(CrossProtocol.C_CROSS_VISIT_PLAYER_CLINIC_RESP, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
